<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background: red;
        }
    </style>
</head>
<body>
    <div id="div" >
    </div>
    <button id="btn" style="display: block">change</button>
    <script>
        var btn=document.getElementById("btn");
        var div=document.getElementById("div");
        btn.onclick=function(){
           let value=div.style.display;
        //    if(value=="block"){
        //     div.style.display="none";
        //    }else{
        //     div.style.display="block";
        //    }
        div.style.display=(value=="block")?"none":"block";
        }    
    </script>
</body>
</html>